﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Emoney.DataAccess;
using LiuYan.Base;
using LiuYan.Entity;


namespace LiuYan.Service
{
    public class HdImgService
    {
        /// <summary>
        /// 编辑轮播图片
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Edit(TB_HdImg entity)
        {
            SqlParameter[] parameters=new SqlParameter[]
            {
                new SqlParameter("Id",SqlDbType.Int),
                new SqlParameter("Img",SqlDbType.VarChar,100),
                new SqlParameter("Url",SqlDbType.VarChar,50),
            };
            parameters[0].Value = entity.Id;
            parameters[1].Value = entity.Img;
            parameters[2].Value = entity.Url;
            string sql = entity.Id==0?
                "insert into TB_HdImg(Img,Url) values(@Img,@Url)" :
                "update TB_HdImg set img=@Img,url=@Url where id=@Id";
            return SqlHelper.ExecuteNonQuery(Connection.conStr, CommandType.Text, sql, parameters);
        }

        public DataTable GetList()
        {
            string sql = "select * from TB_HdImg";
            return SqlHelper.ExecuteDataset(Connection.conStr, CommandType.Text, sql).Tables[0];
        }
    }
}
